<?php
namespace app\index\controller;
use app\common\enums\ResultEnum;
use app\common\utils\OssFlies;
use app\common\utils\ResultVOUtil;
use think\Request;

class File {
    
    protected $ossFiles;
    
    public function __construct(OssFlies $ossFiles)
    {
        $this->ossFiles = $ossFiles;
    }
    
    public function upload(Request $request){
        $file = $request->file('file');
        if(!empty($file)){
            $url = $this->ossFiles->uploadOss($file, '');
            if(!empty($url)){
                return ResultVOUtil::success($url);
            }else{
                return ResultVOUtil::error(ResultEnum::OSS_UPLOAD_ERROR);
            }
        }else{
            return ResultVOUtil::error(ResultEnum::ERROR);
        }
        
    }
    
    
}